<?php
	$page     = isset($_POST['page']) ? $_POST['page'] : '1';
	$name1    = isset($_POST['name1']) ? $_POST['name1'] : '';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Cache-Control" content="No-Cache">
	<meta http-equiv="Pragma" content="No-Cache">

	<title>운세의신</title>
    
    <link rel="stylesheet" type="text/css" href="/css/common.css">
    <link rel="stylesheet" type="text/css" href="/css/sub.css">
	<link rel="stylesheet" type="text/css" href="/css/free.css">

	<link href="/css/lib/myconfig.jquery.validate.css" rel="stylesheet" type="text/css"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script src="/js/lib/jquery.validate.min.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			
			// 결과 내용 숨김
			$(".result").each(function(index) {
				// alert($(this).text());
				$(this).hide();
			});

			// 결과 제목 클릭 시 내용 보이기
			$(".result_title").each(function(index) {
				$(this).click(function() {
					$(".result").hide();
					$(".result").eq(index).show();
					$(".result_title").removeClass("on");
					$(this).addClass("on");
				});
			});

			// 검색어 링크 설정
			$(".dream1_cont ul li a").each(function(index) {
				$(this).click(function() {
					search($(this).text(), '1', $("#dream_cate").val());
				});
			});

			var msg = '검색어를 입력하세요.';
			if ($("#name1").val() == '') {
				$("#name1").val(msg);
			}
			$("#name1").bind({
				focus: function() {
					if( $(this).val() == msg ) {
						$(this).val('');
					}
				},
				blur: function() {
					if( $(this).val() == '') {
						$(this).val(msg);
					}
				}
			});
			
			$("#frm_search").validate({
				rules: {
					search_keyword: "required"
				},
				messages: {
					search_keyword: "검색어를 입력하세요."
				},
				submitHandler: function(form) {
					var keyword = $("#name1").val();
					if (keyword == '' || keyword == msg) {
						alert("검색어를 입력하세요.");
						$("#name1").focus();
					} else {
						form.submit();
					}
				}
			});
			
			$("#recomm_key li a").each(function(index) {
//				console.log($(this).text());
				$(this).click(function() {
//					console.log($(this).text());
					search($(this).text(), 1, 0);
				});
			});
		});
		
		function search(keyword, page, dream_cate) {
			$("#frm_search #dream_cate").val(dream_cate);
			$("#frm_search #page").val(page);
			$("#frm_search #name1").val(keyword);
			$("#frm_search").submit();
		}
		
		function goPage(page) {
			$("#frm_search #page").val(page);
			$("#frm_search").submit();
		}
	</script>
</head>
<body>
<div id="wrap">
	<!-- Header -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/main_header.php'; ?>
	<!--// Header -->
    
    <!--커튼 데코레이션-->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/drape.php'; ?>
	<!--//커튼 데코레이션-->
    
    <!--컨텐츠-->
	<div id="content">
		<!--휘장-->
		<div class="keybox1"> </div>
		<!--//휘장-->
		
		<p class="key_visual"><img src="/images/sub/free/free_visual.png" alt="무료운세" /></p>	
		
		<!--왼쪽컨텐츠-->
		<div class="assistant">
			<!--왼쪽 메뉴-->
			<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/inc_lnb.php'; ?>
			<!--// 왼쪽 메뉴-->

			<!--추천테마-->
			<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/static/theme2.php'; ?>
			<!--//추천테마-->

			<!--회원가입-->
			<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/static/member_join.php'; ?>
			<!--//회원가입-->

			<!--고객센터-->
			<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/static/cs.php'; ?>
			<!--//고객센터_추가-->
		</div>
		<!--//왼쪽컨텐츠-->

		<!-- 메인컨텐츠-->
		<div class="cont">
        
	 		<!-- Contents -->
			<div class="dream1">
				<h3 class="freetit"><img src="/images/free/free_dream_banner1.png" alt="태몽" /></h3>
				<div class="box">
				
                    <!--꿈해몽검색-->
					<div class="search">
						<h4><img src="/images/dream/sstit2.png" /></h4>
						<form name="frm_search" id="frm_search" method="post" action="/unse/free/dreambirth/result">
	                        <fieldset>
	                            <input type="hidden" name="page" id="page" value="<?=$page?>" />
	                            <span><input type="text" name="name1" id="name1" value="<?=$name1?>" /></span>
								<button title="검색" type="submit" value="검색" ></button>
								 <!--오토 스타-->
								<ul class="bn_s" id="recomm_key">
									<li><a href="javascript:;">거북이</a></li>
									<li>/</li>
									<li><a href="javascript:;">용</a></li>
									<li>/</li>
									<li><a href="javascript:;">임신부</a></li>
									<li>/</li>
									<li><a href="javascript:;">돼지</a></li>
									<li>/</li>
									<li><a href="javascript:;">꽃</a></li>
								   	<li>/</li>
									<li><a href="javascript:;">강</a></li>
								</ul>
								<!--//꿈해몽검색-->
							</fieldset>
                        </form>
					</div>
					<!--//꿈해몽검색-->
				
					<div class="conts">
						<h4>검색결과</h4>
						<div class="box">
<?	if($contents['F007']['total_count'] > 0) : ?>
							<div class="title">
								&quot;<span class="key"><?=$name1?></span>&quot; 관련 태몽 검색 내용입니다.
							</div><!--title-->
<?	else : ?>
							검색된 결과가 없습니다.
<?	endif ?>
<?	foreach ($contents['F007']['result_list'] as $item) : ?>
							<dl>
								<dt class="result_title"><a href="javascript:;"><?=str_replace($name1, '<span class="key">'.$name1.'</span>', $item['db_title']); ?></a></dt>
								<dd class="result"><?=$item['db_data']?></dd>
							</dl>
<?	endforeach ?>
						<!--페이지 네비게이션-->
                    	<div class="pageNavi">
<?	for($i = 1 ; $i <= $contents['F007']['lastpage']; $i++) : ?>
<?		if ($i == $page) : ?>
                        	<a href="javascript:;" class="over"><?=$i?></a> 
<?		else : ?>
							<a href="javascript:goPage('<?=$i?>')"><?=$i?></a>
<?		endif ?>
<?	endfor ?>
                        </div>
                        <!--//페이지 네비게이션-->

						</div><!--box-->
					</div><!--conts-->
				</div><!--box-->
			</div>
			<!--dream1--> 
		</div>	
		<!--// Contents -->
        <!--서비스배너-->
        <? include_once $_SERVER['DOCUMENT_ROOT'].'/include/static/bn_service.php'; ?>
        <!--//서비스배너--> 
	</div>
    <!--// 메인컨텐츠-->

	<!-- Footer -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/main_footer.php'; ?>
	<!--// Footer -->
   
</div>
</body>
</html>